import { TState } from "../../../Message/Db/Tables/TState";
import { StringHelper } from "../../../com/gengine/utils/StringHelper";
import { DescConfig } from "./DescConfig";
import { ConfigManager } from "../../../com/gengine/resource/ConfigManager";
type int = number;
//class SkillStateConfig
    
    export  class SkillStateConfig
    {
        constructor()
        {
            
            this._map = new Map<any, any> /* flash.utils.Dictionary */();
            if (SkillStateConfig._instance != null) 
            {
                throw new Error(" ResConfig 单例 ");
            }
            this.init();
            return;
        }

        /* internal  */write(arg1: Object): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=0;
            var loc4=arg1;
            for(loc2 of loc4) 
            {
                loc1 = new TState();
                loc1.stateId = loc2.stateId;
                loc1.name = StringHelper.getString(loc2.name);
                loc1.type = loc2.type;
                loc1.category = loc2.category;
                loc1.gainOrLoss = loc2.gainOrLoss;
                loc1.level = loc2.level;
                loc1.stateEffect = loc2.stateEffect;
                loc1.effectCount = loc2.effectCount;
                loc1.lastTime = loc2.lastTime;
                loc1.timeType = loc2.timeType;
                loc1.removeType = loc2.removeType;
                loc1.set = loc2.set;
                loc1.description = StringHelper.getString(loc2.description);
                loc1.icon = StringHelper.getString(loc2.icon);
                loc1.stateModel = loc2.stateModel;
                loc1.group = loc2.group;
                loc1.descId = loc2.descId;
                if (loc1.descId > 0) 
                {
                    loc1.description = DescConfig.instance.getDescAlyzObj(loc1.descId, loc1);
                }
                this._map[loc1.stateId] = loc1;
            }
            return;
        }

        public init(): void
        {
            var loc1=ConfigManager.instance.getJSONByFileName("t_state.json");
            this.write(loc1);
            return;
        }

        public getInfoByName(arg1: int): TState
        {
            return this._map[arg1];
        }

        public getInfoByGroup(arg1: int): TState
        {
            var loc1=null;
            var loc2=0;
            var loc3=this._map;
            for(loc1 of loc3) 
            {
                if (loc1.group != arg1) 
                {
                    continue;
                }
                return loc1;
            }
            return null;
        }

        public static get instance(): SkillStateConfig
        {
            if (SkillStateConfig._instance == null) 
            {
                SkillStateConfig._instance = new SkillStateConfig();
            }
            return SkillStateConfig._instance;
        }

        /* internal */ /* var */_map: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ static /* var */_instance: SkillStateConfig;
    }
